package com.milkshopbackend.milkshop.Service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.milkshopbackend.milkshop.Service.UserOperationLogService;
import com.milkshopbackend.milkshop.entity.UserOperationLog;
import com.milkshopbackend.milkshop.mapper.UserOperationLogMapper;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;

@Service
public class UserOperationLogServiceImpl extends ServiceImpl<UserOperationLogMapper, UserOperationLog> implements UserOperationLogService {

    @Override
    public void logOperation(Long userId, String operationType, String operationDesc, String ipAddress, String userAgent) {
        UserOperationLog log = new UserOperationLog();
        log.setUserId(userId);
        log.setOperationType(operationType);
        log.setOperationDesc(operationDesc);
        log.setOperationTime(LocalDateTime.now());
        log.setIpAddress(ipAddress);
        log.setUserAgent(userAgent);
        save(log);
    }
} 